﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HistoryToMail
{
    public partial class PluginSettingsForm : Form
    {
        private PluginSettings settings;

        private void LoadSettings()
        {
            if (settings == null) return;
            computerName.Text = settings.computerName;
            idleTime.Value = settings.idleTime;
            loggerEnable.Checked = settings.logEnable;
            mailFilterLabel.Text = settings.mailFilterLabel;
            maxMsgNumberToSend.Value = settings.maxMsgNumberToSend;
        }

        private void SaveSettings()
        {
            if (settings == null) settings = new PluginSettings();
            settings.computerName = computerName.Text;
            settings.idleTime = (int) idleTime.Value;
            settings.logEnable = loggerEnable.Checked;
            settings.mailFilterLabel = mailFilterLabel.Text;
            settings.maxMsgNumberToSend = (int) maxMsgNumberToSend.Value;
        }

        public PluginSettingsForm(PluginSettings settings)
        {
            InitializeComponent();
            this.settings = settings;
            LoadSettings();
        }

        private void smtpSettingButton_Click(object sender, EventArgs e)
        {
            settings.smtpSettings.showSettingsDialog();
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            SaveSettings();
            Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
